home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / grub.d / 30_os-prober < prev    next >
Text File  |  2009-10-29  |  5KB  |  216 lines

  1. #! /bin/sh -e
  2.  
  3. # grub-mkconfig helper script.
  4. # Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
  5. #
  6. # GRUB is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # GRUB is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. prefix=/usr
  20. exec_prefix=${prefix}
  21. libdir=${exec_prefix}/lib
  22.  
  23. . ${libdir}/grub/grub-mkconfig_lib
  24.  
  25. found_other_os=
  26.  
  27. adjust_timeout () {
  28.   if [ "x${found_other_os}" = "x" ] ; then
  29.     if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
  30.       if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
  31.     verbose=
  32.       else
  33.     verbose=" --verbose"
  34.       fi
  35.  
  36.       if [ "x${GRUB_HIDDEN_TIMEOUT}" = "x0" ] ; then
  37.     cat <<EOF
  38. if [ \${timeout} != -1 ]; then
  39.   if keystatus; then
  40.     if keystatus --shift; then
  41.       set timeout=-1
  42.     else
  43.       set timeout=0
  44.     fi
  45.   else
  46.     if sleep$verbose --interruptible 3 ; then
  47.       set timeout=0
  48.     fi
  49.   fi
  50. fi
  51. EOF
  52.       else
  53.     cat << EOF
  54. if [ \${timeout} != -1 ]; then
  55.   if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
  56.     set timeout=0
  57.   fi
  58. fi
  59. EOF
  60.       fi
  61.     fi
  62.   fi
  63. }
  64.  
  65. if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  66.   adjust_timeout
  67.   exit 0
  68. fi
  69.  
  70. if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
  71.   # missing os-prober and/or linux-boot-prober
  72.   adjust_timeout
  73.   exit 0
  74. fi
  75.  
  76. OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
  77. if [ -z "${OSPROBED}" ] ; then
  78.   # empty os-prober output, nothing doing
  79.   adjust_timeout
  80.   exit 0
  81. fi
  82.  
  83. for OS in ${OSPROBED} ; do
  84.   DEVICE="`echo ${OS} | cut -d ':' -f 1`"
  85.   LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
  86.   LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  87.   BOOT="`echo ${OS} | cut -d ':' -f 4`"
  88.  
  89.   if [ -z "${LONGNAME}" ] ; then
  90.     LONGNAME="${LABEL}"
  91.   fi
  92.  
  93.   echo "Found ${LONGNAME} on ${DEVICE}" >&2
  94.   found_other_os=1
  95.  
  96.   case ${BOOT} in
  97.     chain)
  98.  
  99.       cat << EOF
  100. menuentry "${LONGNAME} (on ${DEVICE})" {
  101. EOF
  102.       save_default_entry | sed -e "s/^/\t/"
  103.       prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  104.  
  105.       case ${LONGNAME} in
  106.     Windows\ Vista*|Windows\ 7*)
  107.     ;;
  108.     *)
  109.       cat << EOF
  110.     drivemap -s (hd0) \${root}
  111. EOF
  112.     ;;
  113.       esac
  114.  
  115.       cat <<EOF
  116.     chainloader +1
  117. }
  118. EOF
  119.     ;;
  120.     linux)
  121.       LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
  122.  
  123.       for LINUX in ${LINUXPROBED} ; do
  124.         LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
  125.         LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
  126.         LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
  127.         LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
  128.         LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
  129.         LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
  130.  
  131.         if [ -z "${LLABEL}" ] ; then
  132.           LLABEL="${LONGNAME}"
  133.         fi
  134.  
  135.          if [ "${LROOT}" != "${LBOOT}" ]; then
  136.            LKERNEL="${LKERNEL#/boot}"
  137.            LINITRD="${LINITRD#/boot}"
  138.          fi
  139.  
  140.         cat << EOF
  141. menuentry "${LLABEL} (on ${DEVICE})" {
  142. EOF
  143.     save_default_entry | sed -e "s/^/\t/"
  144.     prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/"
  145.     cat <<  EOF
  146.     linux ${LKERNEL} ${LPARAMS}
  147. EOF
  148.         if [ -n "${LINITRD}" ] ; then
  149.           cat << EOF
  150.     initrd ${LINITRD}
  151. EOF
  152.         fi
  153.         cat << EOF
  154. }
  155. EOF
  156.       done
  157.     ;;
  158.     macosx)
  159.       OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
  160.         cat << EOF
  161. menuentry "${LONGNAME} (on ${DEVICE})" {
  162. EOF
  163.     save_default_entry | sed -e "s/^/\t/"
  164.     prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  165.     cat << EOF
  166.         insmod vbe
  167.         do_resume=0
  168.         if [ /var/vm/sleepimage -nt10 / ]; then
  169.            if xnu_resume /var/vm/sleepimage; then
  170.              do_resume=1
  171.            fi
  172.         fi
  173.         if [ \$do_resume == 0 ]; then
  174.            xnu_uuid ${OSXUUID} uuid
  175.            if [ -f /Extra/DSDT.aml ]; then
  176.               acpi -e /Extra/DSDT.aml
  177.            fi
  178.            xnu_kernel /mach_kernel boot-uuid=\${uuid} rd=*uuid
  179.            if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
  180.               xnu_mkext /System/Library/Extensions.mkext
  181.            else
  182.               xnu_kextdir /System/Library/Extensions
  183.            fi
  184.            if [ -f /Extra/Extensions.mkext ]; then
  185.               xnu_mkext /Extra/Extensions.mkext
  186.            fi
  187.            if [ -d /Extra/Extensions ]; then
  188.               xnu_kextdir /Extra/Extensions
  189.            fi
  190.            if [ -f /Extra/devtree.txt ]; then
  191.               xnu_devtree /Extra/devtree.txt
  192.            fi
  193.            if [ -f /Extra/splash.jpg ]; then
  194.               insmod jpeg
  195.               xnu_splash /Extra/splash.jpg
  196.            fi
  197.            if [ -f /Extra/splash.png ]; then
  198.               insmod png
  199.               xnu_splash /Extra/splash.png
  200.            fi
  201.            if [ -f /Extra/splash.tga ]; then
  202.               insmod tga
  203.               xnu_splash /Extra/splash.tga
  204.            fi
  205.         fi
  206. }
  207. EOF
  208.     ;;
  209.     hurd|*)
  210.       echo "  ${LONGNAME} is not yet supported by grub-mkconfig." >&2
  211.     ;;
  212.   esac
  213. done
  214.  
  215. adjust_timeout
  216.